<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<meta charset="utf-8">
	<title>入库统计</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
	<meta name="description" content="">
	<meta name="author" content="">
	<!-- STYLESHEETS --><!--[if lt IE 9]><script src="../../js/flot/excanvas.min.js"></script><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script><![endif]-->
	<link rel="stylesheet" type="text/css" href="../../css/cloud-admin.css" >
	<link rel="stylesheet" type="text/css"  href="../../css/themes/default.css" id="skin-switcher" >
	<link rel="stylesheet" type="text/css"  href="../../css/responsive.css" >	
	<link href="../../font-awesome/css/font-awesome.min.css" rel="stylesheet">
	<!-- SELECT2 -->
	<link rel="stylesheet" type="text/css" href="../../js/select2/select2.min.css" />
	<!-- UNIFORM -->
	<link rel="stylesheet" type="text/css" href="../../js/uniform/css/uniform.default.min.css" />
	<!-- datatable -->
    <link rel="stylesheet" href="../../js/datatables/datatable.css">
    <link rel="stylesheet" href="../../js/datepicker/datepicker.css">
	<!-- FONTS 
	<link href='http://fonts.useso.com/css?family=Open+Sans:300,400,600,700' rel='stylesheet' type='text/css'>
-->
</head>
<body>
	<header class="navbar clearfix" id="header">
	</header>
	
	<!-- PAGE -->
	<section id="page">
				<!-- SIDEBAR -->
				<div id="sidebar" class="sidebar">
					<div class="sidebar-menu nav-collapse">
						
						<!-- SIDEBAR MENU -->
						<ul>							
							
						</ul>
						<!-- /SIDEBAR MENU -->
					</div>

				</div>
				<!-- /SIDEBAR -->
		<div id="main-content">
			
			<div class="container">
				<div class="row">
					<div id="content" class="col-lg-12">
						<!-- PAGE HEADER-->
						<div class="row">
							<div class="col-sm-12">
								<div class="page-header">
									<!-- STYLER -->
									
									<!-- /STYLER -->
									<!-- BREADCRUMBS -->
									<ul class="breadcrumb">
										<li>
											<i class="fa fa-home"></i>
											<a href="index.html">首页</a>
										</li>
										<li>
											<a href="#">合同管理</a>
										</li>
										<li>入库统计</li>
									</ul>
									<!-- /BREADCRUMBS -->
									
								</div>
							</div>
						</div>
						<!-- /PAGE HEADER -->
						<!-- FORMS QUERY-->
						<div class="row">
							<div class="col-md-12">
								<div class="row">
									<div class="col-md-12">
										<div class="box border primary">
											<div class="box-title">
												<h4><i class="fa fa-bars"></i>查询条件</h4>
											</div>
											<div class="box-body big" style="padding:10px;">												
												<form class="form-horizontal" role="form" id="form_search" method="post" action="../../admin/purchase/exportPurchaseReport.do">
												  <div class="form-group mrg-bt10">
													<label class="col-sm-1 control-label" style="width: 130px;">供应商名称：</label>
													<div class="col-sm-2">
													  <input type="text" class="form-control" name="supplierName" placeholder="">
													</div>
													
													<label class="col-sm-1 control-label" style="width: 120px">合同编号：</label>
													<div class="col-sm-2">
													  <input type="text" class="form-control" name="contractCode" placeholder="">
													</div>
													
													<label class="col-sm-1 control-label" style="width: 130px">SKU/物料编码：</label>
													<div class="col-sm-2">
													  <input type="text" class="form-control" name="skuCode" placeholder="">
													</div>
													<div class="col-sm-1">
									       				<a class="btn btn-primary search">查询</a>
													</div>
												</div>
												 <div class="form-group mrg-bt10" style="display:none;">
													<label class="col-sm-1 control-label" style="width: 120px">入库时间：</label>
													<div class="col-sm-3" style="display:inline-flex">
													<div class="col-sm-2" style="width:130px;padding-left:5px">
														 <input type="text" name="startDate"  class="form-control bootstrap-datepicker">
													</div>
													<div style="width: 20px">至</div>
														<div class="float-left" style="width:100px">
															 <input type="text" name="endDate" class="form-control bootstrap-datepicker">
														</div>	
													</div>
													
												  </div>
												 </form>
											</div>
										</div>
									</div>
								</div>		
						    </div>
						</div>
									
									<div class="row" style="height: 30px;">
								<div class="col-md-12">
									<div class="box ">
										
										<a href="javascript:;"  class="btn btn-warning export">
											<i class="fa  fa-copy"></i> 导出数据
										</a>
									</div>
								</div>
					    </div>
					    <div class="row">
								<!-- TABLES -->
								<div class="col-md-12">
									<!-- BOX -->
									<div class="box border primary">
										<div class="box-title">
											<h4><i class="fa fa-table"></i>总计：<span id="total"></span> 条</h4>

										</div>
										<div class="box-body">
											<table id="db_list" cellpadding="0" cellspacing="0" border="0" class="datatable table table-striped table-bordered table-hover">
												
											</table>
										</div>
									</div>
									<!-- /BOX -->
								</div>
							</div>
							<!-- /TABLES -->
						
						
						<div class="footer-tools">
							<span class="go-top">
								<i class="fa fa-chevron-up"></i> Top
							</span>
						</div>
					</div><!-- /CONTENT-->
				</div>
			</div>
		</div>
	</section>
	<!--/PAGE -->
<!-- JQUERY -->
<script src="../../js/jquery/jquery-2.0.3.min.js"></script>
<script src="../../js/common.js"></script>
<!-- JQUERY UI-->
<script src="../../js/jquery-ui-1.10.3.custom/js/jquery-ui-1.10.3.custom.min.js"></script>
<!-- BOOTSTRAP -->
<script src="../../bootstrap-dist/js/bootstrap.min.js"></script>
<!-- SLIMSCROLL -->
<script type="text/javascript" src="../../js/jQuery-slimScroll-1.3.0/jquery.slimscroll.min.js"></script>
<script type="text/javascript" src="../../js/jQuery-slimScroll-1.3.0/slimScrollHorizontal.min.js"></script>
<!-- BLOCK UI -->
<script type="text/javascript" src="../../js/jQuery-BlockUI/jquery.blockUI.min.js"></script>
<!--bootbox-->
<script type="text/javascript" src="../../js/bootbox/bootbox.min.js"></script>
<!-- AUTOSIZE -->
<script type="text/javascript" src="../../js/autosize/jquery.autosize.min.js"></script>
<!-- spinner -->
<script src="../../js/spinner/spin.js"></script>
<!-- bootstrap-fileupload -->
<script type="text/javascript" src="../../js/jquery-upload/js/jquery.iframe-transport.js"></script>
<script type="text/javascript" src="../../js/jquery-upload/js/jquery.fileupload.min.js"></script>
<script type="text/javascript" src="../../js/jquery-upload/js/jquery.fileupload-process.min.js"></script>
<script type="text/javascript" src="../../js/jquery-upload/js/jquery.fileupload-validate.min.js"></script>

<!-- INPUT MASK -->
<script type="text/javascript" src="../../js/bootstrap-inputmask/bootstrap-inputmask.min.js"></script>

<!-- SELECT2 -->
<script type="text/javascript" src="../../js/select2/select2.min.js"></script>
<!-- UNIFORM -->
<script type="text/javascript" src="../../js/uniform/jquery.uniform.min.js"></script>
<!-- WIZARD -->
<script src="../../js/bootstrap-wizard/jquery.bootstrap.wizard.min.js"></script>
<!-- WIZARD -->
<script src="../../js/jquery-validate/jquery.validate.min.js"></script>
<script src="../../js/jquery-validate/additional-methods.min.js"></script>
<script src="../../js/bootstrap-wizard/form-wizard.js"></script>
<script language="javascript" type="text/javascript" src="../../js/My97DatePicker/WdatePicker.js"></script>
<!-- NESTABLE LISTS -->
<script type="text/javascript" src="../../js/nestable/jquery.nestable.min.js"></script>
<!-- COOKIE -->
<script type="text/javascript" src="../../js/jQuery-Cookie/jquery.cookie.min.js"></script>
<!-- CUSTOM SCRIPT -->
<script src="../../js/script.js"></script>

<script src="../../js/Sortable.min.js"></script>

<!-- DATA TABLES -->
<script type="text/javascript" src="../../js/datatables/bootstrap-select.js"></script>
<script type="text/javascript" src="../../js/datatables/datatable.js"></script>
<script type="text/javascript" src="../../js/datatables/datatable-bootstrap.js"></script>
<script type="text/javascript" src="../../js/datatables/datatable-tabletools.js"></script>
<script type="text/javascript" src="../../js/datatables/fnAddTr.js"></script>
		<script type="text/javascript" src="../../js/datepicker/datepicker.js"></script>
	
		<script>		
		var Coupon=function(){
	         var  $mainDataTable=null;      
	         var searchResult=function(){
/* 	         
	          var startDate=$("input[name=startDate]").val();
	          var endDate=$("input[name=endDate]").val();   */ 
	          var suppliername=$("input[name=supplierName]").val();
			  var contractcode=$("input[name=contractCode]").val();
	          var skucode=$("input[name=skuCode]").val();
	          var url=App.getContextPath()+"admin/purchase/searchPurchaseReport.do?supplierName="+suppliername;
	          
			    /*
	            if(startDate!="")
					url+="&startDate="+startDate;
				if(endDate!="")
				   url+="&endDate="+$.dateAdd(endDate);
				*/
				
				if(contractcode!="")
				   url+="&contractCode="+contractcode;
				if(skucode!="")
				   url+="&skuCode="+skucode;
				   
			       if($mainDataTable){
			           $mainDataTable.api().ajax.url(url).load();	   		
		   		       return;	
			        }
		           var dtSetting = $.dataTableSetting({					
							"ajaxSource" :url,
							"serverSide" : true,
							"bFilter" : false,// 去掉搜索框
							"bLengthChange" : true,// 每页显示数量							
							"sScrollX":"100%",
							"sScrollXInner": "100%",
							"iDisplayLength": 25,
							"bSort" : false,					
							"aoColumns" : [ {
								"mDataProp" : "skuCode",
								"sTitle" : "SKU/物料编码",
								"width" : "8%"				
							},{
								"mDataProp" : "sizeName",
								"sTitle" : "尺码",
								"width" : "6%"				
							}, {
								"mDataProp" : "contractCode",
								"sTitle" : "合同编号",
								"width" : "8%",
								"render":function(data, type, row){
									return "<a href='/pages/contract/add_contract.html?opType=view&id="+row.contractId+"'>"+row.contractCode+"</a>";
								}
							}, {
								"mDataProp" : "supplierName",
								"sTitle" : "供应商",
								"width" : "8%",
								"render":function(data, type, row){
									return "<a href='/pages/contract/new_supply.html?flag=1&id="+row.supplierId+"'>"+row.supplierName+"</a>";
								}
							}, {
								"mDataProp" : "productName",
								"sTitle" : "商品/物料名称",
								"width" : "8%"
							}, {
								"mDataProp" : "price",
								"sTitle" : "单价(元)",
								"width" : "8%",
							}, {
								
								"sTitle" : "合同到货时间",
								"width" : "8%",
								"render":function(data, type, row){
								  return $.getLocalDate(row.arrivedDate);
								}
							}, {
								"mDataProp" : "quantity",
								"sTitle" : "合同件数",
								"width" : "8%",
							}
							, {
								"mDataProp" : "useNum",
								"sTitle" : "进货单件数",
								"width" : "8%",
								"render":function(data, type, row){
								   return "<a href='javascript:void(0);' onclick=JinHuoAmount('"+row.skuCode+"','"+row.contractCode+"');>"+row.purchaseAmount+"</a>";
								}
							}, {
								"mDataProp" : "useNum",
								"sTitle" : "入库件数",
								"width" : "8%",
								"render":function(data, type, row){
								   return "<a href='javascript:void(0);' onclick=InAmount('"+row.skuCode+"','"+row.contractCode+"');>"+row.inAmount+"</a>";
								}
							}, {
								"mDataProp" : "useNum",
								"sTitle" : "入库金额",
								"width" : "8%",
								"render":function(data, type, row){
								   return format_thousands(row.inAmount * row.price);
								}
							}]
						});
					
				      $mainDataTable = $("#db_list").dataTable(dtSetting);
	         };
	       
	         
	         return {	         
	         init:function(){
	           $.initDate($("#form_search"),-30,0);
	           
	           $(".export").click(function(){
	        	   $("#form_search").submit();
	           });
	           
	          $(".search").click(searchResult);	
	            searchResult();	          
				
	          }
		    }
	      }();
	      
	      $(function(){
	      	$("#header").load("../head.html");
	        App.init(); //Initialise plugins and elements	        
	      	Coupon.init();
	      	
	      });
		  
		  //进货单件数明细弹层
		  function JinHuoAmount(skucode,contractcode)
		  {
				$.ajax({
					type: "get",
					url: App.getContextPath()+"admin/purchase/getPurchaseDetailBySku.do",
					async: true,
					data: {skuCode:skucode,contractCode:contractcode},
					success: function(result) {
						var str = "";
						if(result !=null)
						{
							for(var i =0;i<result.length;i++)
							{
								str += (i+1) + "、进货单："+result[i].purchase_code;
								str +="，进货件数：" + result[i].quantity;
								str +="<br/>";
							}
						}
						
						$.alert(str);
					}
				});
		  }
		  
		  //入库明细弹层
		  function InAmount(skucode,contractcode)
		  {
				$.ajax({
					type: "get",
					url: App.getContextPath()+"admin/purchase/getPurchaseDetailBySku.do",
					async: true,
					data: {skuCode:skucode,contractCode:contractcode},
					success: function(result) {
						var str = "";
						if(result !=null)
						{
							for(var i =0;i<result.length;i++)
							{
								if(result[i].in_amount > 0){
									str += (i+1) + "、入库单："+result[i].purchase_code+"，入库时间：" + $.getLocalTime(result[i].in_stock_time);
									str +="，入库件数：" + result[i].in_amount;
									str +="<br/>";
								}
							}
						}
						
						$.alert(str);
					}
				});
		  }
		</script>
		<!-- /JAVASCRIPTS -->
</body>
</html>